/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-27 10:41:22
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\EventList.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'
import { EventType } from '../Common/Conversion'

export const EventList = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'createTime@desc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        hideInSearch: true,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            { ...commonTableList.tableName, title: '姓名', rules: true },
            {
                dataIndex: 'eventType',
                title: '事件类别',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: await EventType(),
            },
            {
                dataIndex: 'planEndDate',
                title: '计划完成日期',
                valueType: 'Date',
                ellipsis: true,
                width: 150,
            },
            {
                dataIndex: 'endDate',
                title: '最终完成日期',
                valueType: 'Date',
                ellipsis: true,
                width: 150,
            },
            {
                dataIndex: 'eventStatus',
                title: '事件状态',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.eventStatus,
            },
            { ...commonTableList.remark, title: '内容' },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoOne"
                            title="人员配置"
                            twoTitle="电子围栏打卡人员配置"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'EventList',
                                actionRef,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
